package org.pictual.controller.mainPackage;

import java.util.Arrays;
import java.util.Vector;

public class Language
{
    public static final int ENGLISH = 0;
    public static final int SPANISH = 1;
    public static final int GERMAN = 2;
    public static final int FRENCH = 3;


    private static final String[] _wikisDiks = {
        "http://en.wiktionary.org/wiki/",
        "http://es.wiktionary.org/wiki/",
        "http://de.wiktionary.org/wiki/",
        "http://fr.wiktionary.org/wiki/"
    };
    private static final String[] _wikis = {
        "http://en.wikipedia.org/wiki/",
        "http://es.wikipedia.org/wiki/",
        "http://de.wiktionary.org/wiki/",
        "http://fr.wiktionary.org/wiki/"
    };

    private static Vector<String> _langz = new Vector(Arrays.asList(
            "en", "es", "de", "fr"
        ));


    private static Vector<String> _languagesEng = new Vector(Arrays.asList(
        "English", "Spanish", "German", "French"
    ));

    private static Vector<String> _languagesEsp = new Vector(Arrays.asList(
        "Ingl.C3.A9s", "Espa.C3.B1ol", "Alem.C3.A1n", "Franc.C3.A9s"
    ));

    private static Vector<String> _languagesDeu = new Vector(Arrays.asList(
        "Englisch", "Spanisch", "Deutsch", "Franz%C3%B6sisch"
    ));

    private static Vector<String> _languagesFra = new Vector(Arrays.asList(
        "Anglais", "Espagnol", "Allemand", "Fran.C3.A7ais"
    ));

    private static Vector<String> _languagesInEachLang = new Vector(Arrays.asList(
        "English", "Espa.C3.B1ol", "Deutsch", "Fran.C3.A7ais"
    ));


    public static int resolve(String lang){
    	int res = 0;
    	if (lang.equals("en"))
            res = 0;
    	if (lang.equals("es"))
            res = 1;
        if (lang.equals("de"))
            res = 2;
        if (lang.equals("fr"))
            res = 3;
    	return res;
    }
    
    public static String resolve(int lang){
    	String res = null;
    	if (lang==1)
            res = "en";
    	if (lang==2)
            res = "es";
        if (lang==3)
            res = "de";
        if (lang==4)
            res = "fr";
    	return res;
    }

    private static Vector<Vector<String>> _languages;
    static{
        _languages = new Vector<Vector<String>>();
        _languages.addElement(_languagesEng);
        _languages.addElement(_languagesEsp);
        _languages.addElement(_languagesDeu);
        _languages.addElement(_languagesFra);
    }

    public static String Wiki(int language){

        return _wikis[language];
    }

    public static String Wiki(String language){
        int index = _languagesInEachLang.indexOf(language);
        return _wikis[index];
    }

    public static String WikiDik(int language){
        return _wikisDiks[language];
    }

    public static String WikiDik(String language){
        int index = _languagesInEachLang.indexOf(language);
        return _wikisDiks[index];
    }

    public static String LanStr(int inWhatLang, int langIndex){
        Vector<String> v = _languages.elementAt(inWhatLang);
        return v.elementAt(langIndex);
    }

    public static String LanInEachLanStr( int langIndex){
        return _languagesInEachLang.elementAt(langIndex);
    }

    public static int LangIndex(String lang){
        return _languagesInEachLang.indexOf(lang);
    }

    public static boolean isLang(int inWhatLang, String langIndex){
        if(_languages==null){
            return false;
        }

        Vector<String> v = _languages.elementAt(inWhatLang);
        if(v==null){
            return false;
        }
        return v.contains(langIndex);
    }
}

